﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using UcAsp.Models;
namespace UcAsp.Controllers
{
    public class TeachController : Controller
    {
        //
        // GET: /Teach/
        private UcAspNetEntities entities = new UcAspNetEntities();
        public ActionResult Index()
        {
            List<Articles> list = new List<Articles>();
            var query = from c in entities.Articless
                        where c.CategorieID == 10&&c.IsRelease==true
                        orderby c.ID ascending
                        select c;

            int pagesize = 500;
            int pageindex = 0;
            if (Request.QueryString["page"] != null)
            {
                pageindex = int.Parse(Request.QueryString["page"].ToString()) - 1;
            }
            ViewData["PageIndex"] = pageindex + 1;
            ViewData["PageCount"] = (query.Count() + 499) / 500;

            list = query.Skip(pageindex * pagesize).ToList<Articles>().Take(pagesize).ToList();




            return View(list);
        }

    }
}
